"use strict";
cc._RF.push(module, '69d50egjKBGjZUKVHtBXx99', 'SuperChariot');
// scripts/SuperChariot.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("GlobalUserData"),
    s = t("AssemblyItem"),
    l = t("CarConstant"),
    c = t("CarRoleView"),
    d = t("GameConstant"),
    h = t("Util"),
    p = t("Global"),
    u = t("HallConstant"),
    f = t("WXSDK"),
    m = cc._decorator,
    _ = m.ccclass,
    y = m.property,
    g = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.node_content = null, e.node_mecha = null, e.pfb_assembly = null, e.pfb_role = null, e.label_Power = null, e.node_videoIcon = null, e.simGuideView = null, e.roleControl = null, e.equipBodyData = null, e.equipWheelData = [], e.equipWeaponData = [], e.equipToolsData = [], e.equipCarBody = null, e.equipCarWheel = [null, null], e.equipCarWeapon = [null, null], e.equipCarTools = [null, null], e.equipWheelRadius = 0, e.isCarShow = !1, e.btnShowAd = null, e.btnCancel = null, e.btnVideo = null, e.TTBtnVideo = null, e._backCall = null, e.switchCar = function () {
      var t,
          e,
          o,
          i = this;
      this.isCarShow ? (t = 1.5, e = 0, o = 255) : (t = 2, e = 255, o = 0), this.isCarShow = !this.isCarShow, this.scheduleOnce(function () {
        cc.tween(i.node_content).to(.5, {
          opacity: e
        }).start(), cc.tween(i.node_mecha).to(.5, {
          opacity: o
        }).call(function () {
          i.switchCar();
        }).start();
      }, t);
    }, e;
  }

  return n(e, t), e.prototype.start = function () {
    var t = this;
    this.TTBtnVideo.active = !1, h.Util.is_tt() && (this.btnVideo.active = !1, this.TTBtnVideo.active = !0), h.Util.is_tt() && r["default"].bAuditMode && (this.btnCancel.active = !0), h.Util.hideHallBanner(), this.btnShowAd.active = !1, r["default"].nTotalGame, h.Util.is_VIVO() && !r["default"].bAuditMode ? h.Util.showNativeBanner(1, this.btnShowAd) : h.Util.is_OPPO() && h.Util.showNativeBanner(1, this.btnShowAd), this.initSuperCharior(), this.scheduleOnce(function () {
      t.createRole(), t.createCarBody(), t.createCarWheel(), t.createCarWeapon(), t.createCarTools(), t.refreshCarPower();
    }, .2), r["default"].popup = this.node, r["default"].videoTab = 25, h.Util.videoExposure(r["default"].videoTab), this.switchCar(), h.Util.isBannerSwitchOn() ? (h.Util.hideBanner(), setTimeout(function () {
      f["default"].getIntance().show_majia_banner(function () {
        t.node.getChildByName("frame").y = 110;
      });
    }, 1e3 * r["default"].majiaDelay)) : (this.node.getChildByName("frame").y = 110, h.Util.showBanner(!1, !0));
  }, e.prototype.onDisable = function () {
    f["default"].getIntance().hide_majia_banner(), h.Util.hideBanner();
  }, e.prototype.init = function (t, e) {
    this._carIndex = t, this._backCall = e, this.node_videoIcon.active = !0, r["default"].nGuideStep == u.Guide_Step.trySuperCar && (this.simGuideView.active = !0, this.node_videoIcon.active = !1), r["default"].saveGuideStepData(u.Guide_Step.Finish);
  }, e.prototype.initSuperCharior = function () {
    var t = Math.random() < .3 ? l.Weapon_ID.Grapeshot : l.Weapon_ID.Gatlin;

    if (!(r["default"].superChariotData.arrWeapon.length > 0 && r["default"].superChariotData.arrWeapon[0].id == t)) {
      r["default"].superChariotData.arrBody = [], r["default"].superChariotData.arrWheel = [], r["default"].superChariotData.arrWeapon = [], r["default"].superChariotData.arrTools = [];

      for (var e = [{
        bodyId: "body05",
        wheel0Id: "wheel01",
        wheel1Id: "wheel01",
        weapon0Id: t,
        tool0Id: l.Tools_ID.Harpoon
      }], o = 0; o < e.length; o++) {
        var i = this.getFistItemData(e[o].bodyId, 5, l.Basics_Items_Type.body, p.Quality.epic, {
          type: l.Basics_Items_Type.weapon,
          id: l.Weapon_ID.Fist,
          buffType: p.BuffType.damage,
          number: 1.5
        }, 5),
            n = this.getFistItemData(e[o].wheel0Id, 5, l.Basics_Items_Type.wheel, p.Quality.common, {
          type: null,
          id: null,
          buffType: p.BuffType.hp,
          number: 0
        }, 5),
            a = this.getFistItemData(e[o].wheel1Id, 5, l.Basics_Items_Type.wheel, p.Quality.common, {
          type: null,
          id: null,
          buffType: p.BuffType.hp,
          number: 0
        }, 5),
            s = this.getFistItemData(e[o].weapon0Id, 5, l.Basics_Items_Type.weapon, p.Quality.common, {
          type: null,
          id: null,
          buffType: p.BuffType.hp,
          number: 0
        }, 5),
            c = this.getFistItemData(e[o].tool0Id, 5, l.Basics_Items_Type.tools, p.Quality.common, {
          type: null,
          id: null,
          buffType: p.BuffType.hp,
          number: 0
        }, 5);
        h.Util.setBuff(n, i), h.Util.setBuff(a, i), h.Util.setBuff(s, i), h.Util.setBuff(c, i), r["default"].superChariotData.arrBody.push(i), r["default"].superChariotData.arrWheel.push(n), r["default"].superChariotData.arrWheel.push(a), r["default"].superChariotData.arrWeapon.push(s), r["default"].superChariotData.arrTools.push(c);
      }
    }
  }, e.prototype.getFistItemData = function (t, e, o, i, n, a) {
    void 0 === i && (i = p.Quality.common), void 0 === n && (n = {
      type: null,
      id: null,
      buffType: p.BuffType.hp,
      number: 0
    }), void 0 === a && (a = 1);
    var r = null;

    switch (o) {
      case l.Basics_Items_Type.body:
        r = l.getBodyData(t);
        break;

      case l.Basics_Items_Type.wheel:
        r = l.getWheelData(t);
        break;

      case l.Basics_Items_Type.weapon:
        r = l.getWeaponData(t);
        break;

      case l.Basics_Items_Type.tools:
        r = l.getToolsData(t);
    }

    return h.Util.getItemData(r.id, r.type, e, l.GetRandomItemHp(r, e), l.GetRandomItemDamage(r, e), l.GetRandomItemElec(r, e), i, n, a);
  }, e.prototype.onClose = function () {
    h.Util.is_VIVO() && !r["default"].bAuditMode && h.Util.showNativeGridAd(), this._backCall(), h.Util.hideRightSingleCustomAd(), this.node.destroy(), h.Util.hideNativeBanner();
  }, e.prototype.onClickNativeBanner = function () {
    h.Util.clickNativeBanner(1);
  }, e.prototype.onDestroy = function () {
    r["default"].popup = null, r["default"].superCarPanel = null;
  }, e.prototype.createRole = function () {
    var t = r["default"].superChariotData.arrBody[0].id;

    if (t) {
      if (!this.roleControl) {
        var e = cc.instantiate(this.pfb_role);
        this.node_content.addChild(e), this.roleControl = e.getComponent(c["default"]);
      }

      this.roleControl.init(this, d.Physics_Car_Tag.Left, t), this.roleControl.playAniIn();
    }
  }, e.prototype.createCarBody = function () {
    var t = r["default"].superChariotData.arrBody[0];

    if (this.equipBodyData = t, !this.equipCarBody) {
      var e = cc.instantiate(this.pfb_assembly);
      this.node_content.addChild(e), this.equipCarBody = e.getComponent(s.AssemblyItem);
    }

    this.equipCarBody.updateItem(null, !0, 0, t, !1, s.Assembly_Type.SuperCar, !0, !0);
  }, e.prototype.createCarWheel = function () {
    for (var t = 0; t < r["default"].superChariotData.arrWheel.length; t++) {
      var e = r["default"].superChariotData.arrWheel[t];

      if (e) {
        this.equipWheelData[t] = e, this.equipWheelRadius = this.equipWheelRadius < e.radius && e.radius;
        var o = cc.instantiate(this.pfb_assembly);
        this.node_content.addChild(o, 20), o.position = l.GetCarBodyData(r["default"].superChariotData.arrBody[0].id).wheelPos[t], this.equipCarWheel[t] = o.getComponent(s.AssemblyItem), this.equipCarWheel[t].updateItem(null, !0, 0, e, !1, s.Assembly_Type.SuperCar);
      } else this.equipWheelData[t] = null, this.equipCarWheel[t] = null;
    }
  }, e.prototype.createCarWeapon = function () {
    for (var t = 0; t < r["default"].superChariotData.arrWeapon.length; t++) {
      var e = r["default"].superChariotData.arrWeapon[t];

      if (e) {
        this.equipWeaponData[t] = e;
        var o = cc.instantiate(this.pfb_assembly);
        this.node_content.addChild(o, 30), o.position = l.GetCarBodyData(r["default"].superChariotData.arrBody[0].id).weaponPos[t], this.equipCarWeapon[t] = o.getComponent(s.AssemblyItem), this.equipCarWeapon[t].updateItem(null, !0, 0, e, !1, s.Assembly_Type.SuperCar);
      } else this.equipWeaponData[t] = null, this.equipCarWeapon[t] = null;
    }
  }, e.prototype.createCarTools = function () {
    for (var t = 0; t < r["default"].superChariotData.arrTools.length; t++) {
      var e = r["default"].superChariotData.arrTools[t];

      if (e) {
        this.equipToolsData[t] = e;
        var o = cc.instantiate(this.pfb_assembly);
        this.node_content.addChild(o, 40), o.position = l.GetCarBodyData(r["default"].superChariotData.arrBody[0].id).toolsPos[t], this.equipCarTools[t] = o.getComponent(s.AssemblyItem), this.equipCarTools[t].updateItem(null, !0, 0, e, !1, s.Assembly_Type.SuperCar);
      } else this.equipToolsData[t] = null, this.equipCarTools[t] = null;
    }
  }, e.prototype.refreshCarPower = function () {
    var t = 0;
    t += h.Util.getOwnItemPower(this.equipBodyData);

    for (var e = 0; e < this.equipWheelData.length; e++) {
      var o = this.equipWheelData[e];
      t += h.Util.getOwnItemPower(o);
    }

    for (e = 0; e < this.equipWeaponData.length; e++) {
      o = this.equipWeaponData[e], t += h.Util.getOwnItemPower(o);
    }

    for (e = 0; e < this.equipToolsData.length; e++) {
      o = this.equipToolsData[e], t += h.Util.getOwnItemPower(o);
    }

    this.label_Power.string = "战力：" + t.toString(), r["default"].superChariotData.power = this.label_Power.string;
  }, e.prototype.onBtnPlaySuperChariot = function () {
    var t = this;
    r["default"].isTryCar = !0, this.node_videoIcon.active ? h.Util.showRewardVideo(function () {
      h.Util.superCarSwapData(!0, t._carIndex), t.onClose();
    }, null, null, !1) : (console.log(r["default"].nGuideStep), h.Util.superCarSwapData(!0, this._carIndex), this.onClose());
  }, a([y(cc.Node)], e.prototype, "node_content", void 0), a([y(cc.Node)], e.prototype, "node_mecha", void 0), a([y(cc.Prefab)], e.prototype, "pfb_assembly", void 0), a([y(cc.Prefab)], e.prototype, "pfb_role", void 0), a([y(cc.Label)], e.prototype, "label_Power", void 0), a([y(cc.Node)], e.prototype, "node_videoIcon", void 0), a([y(cc.Node)], e.prototype, "simGuideView", void 0), a([y(cc.Node)], e.prototype, "btnShowAd", void 0), a([y(cc.Node)], e.prototype, "btnCancel", void 0), a([y(cc.Node)], e.prototype, "btnVideo", void 0), a([y(cc.Node)], e.prototype, "TTBtnVideo", void 0), a([_], e);
}(cc.Component);

o["default"] = g;

cc._RF.pop();